import fileinput, glob, string, sys, os, csv

#it counts the occorrences of species names, sums these for taxa and then prints to the screen those orthogroups that are present only in certain predefined taxa or groups of taxa

orthogroup = glob.glob("OG*.muscle.fasta.bak.cut")   #change extension accordingly

for filename in orthogroup:
    fh = open(filename)
    content = fh.read()
    fh.close()
    Anurida_count = content.count("SRR921564_peptides_isoSingle")   
    Anoplodac_count = content.count("Anoplodactylus")
    Occasjapy_count = content.count("SRR921624_peptides_isoSingle")
    Chthamalu_count = content.count("Crust169_peptides_isoSingle")
    Ixodes_count = content.count("Ixodes_peptides_CDHit_single")
    Acerentom_count = content.count("SRR921562_peptides_isoSingle")
    Leucauge_count = content.count("SRR1145740_peptides_isoSingle")
    Limulus_count = content.count("SRR1145732_peptides_isoSingle")
    Palaemone_count = content.count("Crust115B_peptides_isoSingle")
    Eusarsiel_count = content.count("Crust176b_peptides_isoSingle")
    Craterost_count = content.count("SRR1157986_peptides_isoSingle")
    Penaeus_count = content.count("Penaeus_peptides_isoSingle")
    Lightiell_count = content.count("Crust200_peptides_isoSingle")
    Thermobia_count = content.count("SRR921648_peptides_isoSingle")
    X_fucksco_count = content.count("Crust128_peptides_isoSingle")
    Caprella_count = content.count("Crust160_peptides_isoSingle")
    X_tulumen_count = content.count("Crust116")
    Cryptops_count = content.count("SRR1153457_peptides_isoSingle")
    Tigriopsu_count = content.count("SRR1626906a")
    Strigimia_count = content.count("Strigimia_peptides_CDHit_single")
    Neogonoda_count = content.count("Crust170_peptides_isoSingle")
    Ozestheri_count = content.count("Cae640")
    Meinertel_count = content.count("SRR921617_peptides_isoSingle")
    Glomeride_count = content.count("SRR941771_peptides_isoSingle")
    B_herrodi_count = content.count("Crust105")
    Triops_au_count = content.count("Crust142_peptides_isoSingle")
    Lernea_count = content.count("SRR1107498")
    Cylindrol_count = content.count("Crust197_peptides_isoSingle")
    Calanus_f_count = content.count("Crust123_peptides_isoSingle")
    Caligus_count = content.count("SRR1233153a_peptides_isoSingle")
    TemoraLon_count = content.count("Crust125_peptides_isoSingle")
    DaphniaPu_count = content.count("Dpulex_pep_CDHIT_Single")
    Drosophil_count = content.count("Drosophila_peptides_single")
    Argulus_count = content.count("SRR514120_peptides_isoSingle")
    Godzilliu_count = content.count("Crust130_peptides_isoSingle")
    Paranesid_count = content.count("Crust198_peptides_isoSingle")
    Lasionect_count = content.count("Crust139_peptides_isoSingle")
    Derocheil_count = content.count("Crust194_peptides_isoSingle") 
    Speonebal_count = content.count("Crust138_peptides_isoSingle_neu") 
    Hutchinso_count = content.count("Crust178_peptides_isoSingle") 


    Hexapoda_sum = Drosophil_count + Anurida_count + Occasjapy_count + Acerentom_count + Thermobia_count + Meinertel_count
    Remipedia_sum = X_fucksco_count + X_tulumen_count + Lasionect_count + Godzilliu_count
    Cephalocarida_sum = Lightiell_count + Hutchinso_count
    Branchiopoda_sum = DaphniaPu_count + B_herrodi_count + Triops_au_count + Ozestheri_count

    
    if Hexapoda_sum >= 1 and Branchiopoda_sum >= 1 and Remipedia_sum >= 1 and Cephalocarida_sum >= 1:
        print("Decisive", filename)          
    if Hexapoda_sum < 1 or Branchiopoda_sum < 1 or Remipedia_sum < 1 or Cephalocarida_sum < 1:
        print("Not_Decisive", filename)  

 
